package pools;

import net.rim.device.api.util.ByteVector;

public abstract class Pool {

	private ByteVector buffer = new ByteVector();
	
	public abstract void add(int nextInt);
	
	protected final synchronized void addToBuffer(byte b){
		buffer.addElement(b);
	}
	
	// Returns a copy of the underlying buffer
	public final synchronized byte[] getBuffer(){
		return buffer.toArray();
	}

	// This stores ints with the low order byte first because I don't
	// feel like shifting a mask.
	protected final synchronized void addToBuffer(int nextInt) {
		for(int i = 0; i < 4; i++){
			buffer.addElement((byte)(nextInt & 0xFF));
			nextInt = nextInt >>> 8;
		}
	}

	public abstract String getPoolName();
	
}
